#include <cstdio>

const float
	HG_H = 360.0 / 12.0,
	HG_M = HG_H / 60.0,
	MG_M = 360.0 / 60.0;


float degrees (int h, int m)
{
	float dh, dm, r;
	
	h = h * 60 + m;

	dh = h * HG_M;
	dm = m * MG_M;
	r = dh - dm;
	if (r < 0)
		r += 360.0;
	else if (r >= 360.0)
		r -= 360.0;
	if (r >= 180.0)
		r = 360.0 - r;

	return r;
}


int main ()
{
	int h, m;

	while (scanf("%d:%d", &h, &m), (h > 0 || m > 0))
	{
		printf("%.3f\n", degrees(h,m));
	}

	return 0;
}